package com.example.service;

import com.example.entity.Employee;
import com.example.entity.Organization;
import com.example.exception.CustomException;
import com.example.mapper.EmployeeMapper;
import com.example.mapper.OrganizationMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class OrganizationService {

    @Resource
    private OrganizationMapper organizationMapper;

    public List<Organization> selectAll(Organization organization) {
        return organizationMapper.selectAll(organization);
    }

    //分页查询
    public PageInfo<Organization> selectPage(Organization organization, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Organization> list = organizationMapper.selectAll(organization);
        return PageInfo.of(list);
    }

    public void add(Organization organization) {
        organizationMapper.insert(organization);
    }

    public void update(Organization organization) {
        organizationMapper.update(organization);
    }

    public void delete(Integer id) {
        organizationMapper.delete(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            organizationMapper.delete(id);
        }
    }

}
